/*
 * Sales_EditView.java
 * Final Project Example
 * Created on Oct 9, 2014, 01:59:03 PM
 * by Fairul Filza with Team FA_PemrogrammanLanjut
 */

package Views;

// <editor-fold defaultstate="collapsed" desc="Import Code">
import Controllers.Login_Controller;
import Interfaces.ViewsProcess_Interface;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import org.netbeans.lib.awtextra.AbsoluteConstraints;
import org.netbeans.lib.awtextra.AbsoluteLayout;
// </editor-fold>

/** @author PemrogrammanLanjut_LABIV_TI_05~09 */
public class Login_View extends JFrame implements ViewsProcess_Interface {
    private JPanel PnlFront;
    private JTextField TxtUsername;
    private JPasswordField TxtPassword;
    private JButton BtnEnter;
    private JButton BtnCancel;
    private JLabel LblWallpaper;
    private ImageIcon Image;
    

    // <editor-fold defaultstate="collapsed" desc="Constructor Code">
    public Login_View() {
        PnlFront = new JPanel();
        TxtUsername = new JTextField();
        TxtPassword = new JPasswordField();
        BtnEnter = new JButton();
        BtnCancel = new JButton();
        LblWallpaper = new JLabel();

        initFrameProcess();
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Getter and Setter Code">
    public JLabel getLblWallpaper() {
        return LblWallpaper;
    }

    public void setLblWallpaper(JLabel LblWallpaper) {
        this.LblWallpaper = LblWallpaper;
    }
    public JPanel getPnlFront () {
        return PnlFront;
    }
    public void setPnlFront(JPanel PnlFront) {
        this.PnlFront = PnlFront;
    }
    public JTextField getTxtUsername () {
        return TxtUsername;
    }
    public void setTxtUsername (JTextField TxtUsername) {
        this.TxtUsername = TxtUsername;
    }
    public JPasswordField getTxtPassword () {
        return TxtPassword;
    }
    public void setTxtPassword (JPasswordField TxtPassword) {
        this.TxtPassword = TxtPassword;
    }
    public JButton getBtnEnter () {
        return BtnEnter;
    } 
    public void setBtnEnter (JButton BtnEnter) {
        this.BtnEnter = BtnEnter;
    }
    public JButton getBtnCancel () {
        return BtnCancel;
    }
    public void setBtnCancel (JButton BtnCancel) {
        this.BtnCancel = BtnCancel;
    }
    
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Method Code">
    private void initFrameProcess() {
        initComponents();
        eventControllers();
        imageControllers();
    }

    @Override
    public void initComponents() {
        Font FontStyle = new Font("Tahoma", 1, 12);

        this.setTitle("Login");
        this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        this.getContentPane().setLayout(new AbsoluteLayout());
        this.getContentPane().add(PnlFront, new AbsoluteConstraints(0, 0, 600, 337));

        PnlFront.setLayout(null);
        PnlFront.setBackground(new Color(0, 0, 0));
        PnlFront.setOpaque(true);
        
        
        TxtUsername.setOpaque(true);
        TxtUsername.setBorder(null);
        TxtUsername.setHorizontalAlignment(JLabel.LEADING);
        TxtUsername.setFont(FontStyle);
        PnlFront.add(TxtUsername);
        TxtUsername.setBounds(260, 260, 177, 15);

        TxtPassword.setOpaque(true);
        TxtPassword.setBorder(null);
        TxtPassword.setHorizontalAlignment(JLabel.LEADING);
        TxtPassword.setFont(FontStyle);
        TxtPassword.setEchoChar('*');
        PnlFront.add(TxtPassword);
        TxtPassword.setBounds(260, 284, 177, 15);
        
        BtnEnter.setOpaque(false);
        BtnEnter.setBorderPainted(false);
        BtnEnter.setContentAreaFilled(false);
        BtnEnter.setBorder(null);
        BtnEnter.setVisible(true);
        PnlFront.add(BtnEnter);
        BtnEnter.setBounds(301,308,63,17);
        BtnEnter.setCursor(new Cursor(Cursor.HAND_CURSOR));
        
        BtnCancel.setOpaque(false);
        BtnCancel.setBorderPainted(false);
        BtnCancel.setContentAreaFilled(false);
        BtnCancel.setBorder(null);
        BtnCancel.setVisible(true);
        PnlFront.add(BtnCancel);
        BtnCancel.setBounds(373,308,  63, 17);
        BtnCancel.setCursor(new Cursor(Cursor.HAND_CURSOR));

        LblWallpaper.setText(null);
        LblWallpaper.setBackground(new Color(255, 255, 255));
        LblWallpaper.setOpaque(true);
        PnlFront.add(LblWallpaper);
        LblWallpaper.setBounds(0, 0, 600, 337);

        pack();
        this.setLocationRelativeTo(this);
    }

    @Override
    public void eventControllers() {
        Login_Controller ControlPanel = new Login_Controller(this);
        this.addComponentListener(ControlPanel.EditComponent_Listener);
        this.addWindowListener(ControlPanel.MainWindow_Listener);
        TxtUsername.addKeyListener(ControlPanel.EditKey_Listener);
        TxtPassword.addKeyListener(ControlPanel.EditKey_Listener);
        BtnCancel.addActionListener(ControlPanel.EditButton_Listener);
        BtnEnter.addActionListener(ControlPanel.EditButton_Listener);
        BtnCancel.addMouseListener(ControlPanel.EditButtonImg_Listener);
        BtnEnter.addMouseListener(ControlPanel.EditButtonImg_Listener);
    }

    @Override
    public void imageControllers() {
        Image = new ImageIcon(getClass().getResource("/Images/login_frame.png"));
        LblWallpaper.setIcon(Image);
        Image = new ImageIcon(getClass().getResource("/Images/enter.png"));
        BtnEnter.setIcon(Image);
        Image = new ImageIcon(getClass().getResource("/Images/cancel.png"));
        BtnCancel.setIcon(Image);
        
    }
    // </editor-fold>
}
// End of Code